package com.launcher.wkang.util;

import android.app.ActivityManager;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;

import java.util.Calendar;

public class CurriculumUtil {
    public static void curriculumProhibit(int hour,int minutes,Context context,boolean isProhibit){

        Calendar calendar = Calendar.getInstance();
        long     nowTime  = calendar.getTimeInMillis();//这是当前的时间
        Calendar myCal = Calendar.getInstance();
        myCal.set(Calendar.HOUR_OF_DAY,hour);
        myCal.set(Calendar.MINUTE,minutes);
        long    shutDownTime = myCal.getTimeInMillis();

        Intent intent = new Intent("curriculum.prohibit");
        intent.putExtra("isProhibit",isProhibit);
        PendingIntent pendingIntent = PendingIntent.getService(context,0,intent,0);
        AlarmManager alarm = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);

        alarm.set(AlarmManager.RTC,shutDownTime -nowTime, pendingIntent);
        alarm.setRepeating(AlarmManager.RTC_WAKEUP ,
                shutDownTime -nowTime, 1000*60*60*24, pendingIntent);//
    }

     public static String getTopActivity(Context context){
         ActivityManager mAm = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
         String activityName = mAm.getRunningTasks(1).get(0).topActivity.getClassName();
         return activityName;

     }
}
